package com.netx.cubigraf.shared;
import java.io.IOException;

import com.netx.generics.io.FileSystem;
import com.netx.generics.io.Location;
import com.netx.generics.basic.IntegrityException;
import com.netx.generics.util.Strings;
import com.netx.cubigraf.entities.Referencia;

public class FsUtils {

	public static String getServerPathFor(Referencia ref) {
		return "/Ficheiros/"+ref.data.getYear()+"/"+Strings.valueOf(ref.data.getMonth(), 2)+"/"+ref.toString();
	}
	
	public static FileSystem getClientFS(String hostName, char hostType, String networkName, String networkPassword) throws IOException {
		if(hostType == 'p') {
			return new FileSystem(new Location("//"+hostName+"/Ficheiros"));
		}
		else if(hostType == 'm') {
			return new FileSystem(new Location("//"+hostName+"/"+networkName+"/Desktop/Ficheiros"));
		}
		else {
			throw new IntegrityException(hostType);
		}
	}
}
